import { fetchList } from '../api'

const updateList = list => {
  return {
    type: 'UPDATE_LIST',
    payload: list
  }
}

export const fetchListService = page => {
  return dispatch => {
    return fetch('http://192.168.83.39:3000/api/comment/133998')
    .then(res => res.json())
    .then(res => {
      const { code, data, msg } = res
      if (code === 0) {
        dispatch(updateList(data))
      }
    })
    .catch(error => {
      console.error(error)
    })
  }
} 